<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" />
    <title>添加用户</title>
    <script src="/plugin/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <link href="/plugin/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="/css/form.css" rel="stylesheet"/>

    <script src="/plugin/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
    <script src="/plugin/jquery/jquery.validate.js"></script>

</head>
<body style="margin: 10px;">
<form id="subForm">
    <div class="formDiv" style="width: 95%;" th:object="${secUser}">
        <input  type="hidden" name="id" th:value="*{id}" />
        <input  type="hidden" name="createTime" th:value="*{createTime}" />
        <input  type="hidden" name="deleted" th:value="*{deleted}"/>
        <input  type="hidden" name="orgId" th:value="*{orgId}" />

        <div class="formLine">
            <div class="formInp">
                <span>用&nbsp;户&nbsp;&nbsp;名：</span>
                <input class="blue testTxt" type="text" placeholder="必填" required data-msg-required="不能为空" name="userName" th:value="*{userName}"/>
            </div>
            <div class="formInp">
                <span>账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</span>
                <input class="blue testTxt" placeholder="必填" required data-msg-required="不能为空" type="text" name="account" th:value="*{account}"/>
            </div>
        </div>
        <div class="formLine">
            <div class="formInp">
                <span>手机号码：</span>
                <input class="blue testTxt" placeholder="必填" required data-msg-required="不能为空" type="text" name="mobile" th:value="*{mobile}"/>
            </div>
            <div class="formInp">
                <span>邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱：</span>
                <input class="blue testTxt" type="text" placeholder="必填" required data-msg-required="不能为空" name="email" th:value="*{email}"/>
            </div>
        </div>

        <div class="formLine">
            <div class="formInp">
                <span>性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</span>
                <select class="blue testTxt" name="sex">
                    <span th:if="*{sex  eq 0}">
                        <option selected  value="0">女</option>
                        <option   value="1">男</option>
                    </span>
                    <span th:if="*{sex  eq 1}">
                         <option selected  value="1">男</option>
                        <option   value="0">女</option>
                    </span>
                </select>
            </div>
            <div class="formInp">
                <span>状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：</span>
                <select class="blue testTxt" name="status" th:value="*{status}">
                    <span th:if="*{status  eq 0}">
                        <option selected value="0">不可用</option>
                        <option value="1">可用</option>
                    </span>
                    <span th:if="*{status  eq 1}">
                            <option value="0">不可用</option>
                            <option selected value="1">可用</option>
                    </span>

                </select>
            </div>
        </div>

        <div class="formLine">
            <div class="formInp">
                <span>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：</span>
                <input class="blue testTxt" placeholder="必填" required data-msg-required="不能为空"  type="text" name="addr" th:value="*{addr}"/>
            </div>

            <div class="formInp">
                <span>账号密码：</span>
                <input class="blue testTxt"  type="password" placeholder="必填" required data-msg-required="不能为空" name="userPass" th:value="*{userPass}"/>
            </div>
        </div>

        <div class="formLine">
            <div class="formInp">
                    <button class="btn-blue"  type="submit">保存数据</button>
            </div>
        </div>
    </div>
</form>
</body>
<script type="text/javascript">
    $(function(){
        $("#subForm").validate({
            submitHandler: function() {
                send();
            }
        });
    });


    function send(){
        var data = $("#subForm").serialize();
        $.ajax({
            type: 'POST',
            url: 'update',
            data: data,
            dataType: 'json',
            success: function(data){
                if(data.code==200){
                    parent.callBack();
                }else{
                    $.ligerDialog.error('保存失败');
                }
            },
            error:function(){
                $.ligerDialog.error('保存失败');
            }
        });
    }


</script>
</html>